package org.jeecg.modules.api.controller.music.banner;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.music.entity.vo.HomeBannerVo;
import org.jeecg.modules.music.service.IMusAlbumSongListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Api(tags="音乐系统")
@RestController
@RequestMapping("api/mus/")
public class BannerAPIController {

    @Autowired
    private IMusAlbumSongListService musAlbumSongListService;

    @ApiOperation("API-首页轮播图")
    @RequestMapping(value = "/banner", method = RequestMethod.GET)
    public Result<List<HomeBannerVo>> banner(@RequestParam("type") String type){
        Result<List<HomeBannerVo>> result = new Result<>();

        try {
            if(oConvertUtils.isNotEmpty(type)){
                List<HomeBannerVo> list = musAlbumSongListService.queryHomeBanner(type);
                result.setResult(list);
            }else{
                result.setResult(null);
            }
            result.setSuccess(true);
        } catch (Exception e) {
            log.error(e.getMessage(),e);
        }
        return result;
    }
}
